﻿using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;

public class UiMenu : BaseUi
{
	public ScrollTool ScrollTool; //滚动循环插件
	public InputField dataPath;//显示资源路径
	public InputField copyLevel;
	public InputField contentWidthInput;
	public InputField contentHeightInput;
	public InputField hCountInput;
	public InputField vCountInput;
	public GameObject fenGeIsCheck;
	public GameObject toolTextIsCheck;
	public void init()
	{
		Global.GameProxy.UiMenu = this;
	}
	private void Start()
	{
		dataPath.text = Application.persistentDataPath;
		ScrollTool.refresh();
		refreshInput();
	}
	private void refreshInput()
	{
		contentWidthInput.text = Global.gameData.contentWidth.ToString();
		contentHeightInput.text = Global.gameData.contentHeight.ToString();
		hCountInput.text = Global.gameData.hCount.ToString();
		vCountInput.text = Global.gameData.vCount.ToString();

		fenGeIsCheck.SetActive(Global.gameData.isShowFenGeXian);
		toolTextIsCheck.SetActive(Global.gameData.isShowToolText);
	}
	//点击事件
	public override void _onClick(string btnTag, GameObject obj)
	{
		base._onClick(btnTag, obj);
		switch (btnTag) {
			case "newLevel":
				Global.GameProxy.newLevel();
				break;
			case "newCopy":
				int level = int.Parse(copyLevel.text == "" ? "0" : copyLevel.text);
				Global.GameProxy.newCopy(level);
				break;
			case "save":
				int contentWidth = int.Parse(contentWidthInput.text == "" ? "0" : contentWidthInput.text);
				Global.gameData.contentWidth = contentWidth;
				int contentHeight = int.Parse(contentHeightInput.text == "" ? "0" : contentHeightInput.text);
				Global.gameData.contentHeight = contentHeight;
				int hCount = int.Parse(hCountInput.text == "" ? "0" : hCountInput.text);
				Global.gameData.hCount = hCount;
				int vCount = int.Parse(vCountInput.text == "" ? "0" : vCountInput.text);
				Global.gameData.vCount = vCount;
				refreshInput();
				Global.GameProxy.ControlBox.creatorMapBg();
				break;
			case "isShowFenGeXian":
				Global.gameData.isShowFenGeXian = !Global.gameData.isShowFenGeXian;
				fenGeIsCheck.SetActive(Global.gameData.isShowFenGeXian);
				break;
			case "isShowToolText":
				Global.gameData.isShowToolText = !Global.gameData.isShowToolText;
				toolTextIsCheck.SetActive(Global.gameData.isShowToolText);
				break;
			default:
				Debug.Log("点击了" + btnTag + "未处理");
				break;
		}
	}
}